class Solution {
public:
    int arrayPairSum(vector<int>& nums) {
        ranges::sort(nums);
        int n = nums.size();

        int sum = 0;
        for(int i = 0; i < n; i += 2)
        {
            sum += nums[i];
        }
        return sum;
    }
};
